﻿using System;

namespace Gumini.JulaDB.Expressions.Operators
{
    internal class OrOperator : LogicalOperator
    {
        public OrOperator()
            : base("or") { }
    
        protected override bool? EvaluateCore(bool? a, bool? b)
        {
            // "If numeric values are assigned to FALSE, UNKNOWN and TRUE such that FALSE is less than UNKNOWN and UNKNOWN is less than TRUE,
            // then A AND B AND C... = MIN(A, B, C ...) and A OR B OR C ... = MAX(A, B, C...)."
            return IntegerToBool(
                Math.Max(BoolToInteger(a), BoolToInteger(b)));
        }
    }
}
